package org.Vancl.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.Vancl.Dao.NavigationDao;
import org.Vancl.Dao.menuDao;
import org.Vancl.Dao.ImpI.NavigationDaoImpI;
import org.Vancl.Dao.ImpI.menuDaoImpI;
import org.Vancl.entity.Navigation;
import org.Vancl.entity.menu;

@WebServlet(urlPatterns="/HTmenu.shtml")
public class HTmenuservlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		NavigationDao nd=new NavigationDaoImpI();
		List<Navigation> list=nd.getAll();
		req.setAttribute("list", list);
		
		menuDao md=new menuDaoImpI();
		List<Navigation> menulist=new ArrayList<>();
		for (Navigation navigation : list) {
			List<menu> list2=md.getid(navigation.getN_id());
			navigation.setMe(list2);
			menulist.add(navigation);
		}
		req.setAttribute("menulist", menulist);
		
		
		
		req.getRequestDispatcher("HT/HTmenu.jsp").forward(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
}
